package com.wdh.kjs.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.wdh.kjs.R;
import com.wdh.kjs.fragment.Fm_financerecord_Fragment;
import com.wdh.kjs.fragment.Fm_raisestop_Fragment;
import com.wdh.kjs.fragment.Fm_raisesuccess_Fragment;
import com.wdh.kjs.fragment.Fm_raising_Fragment;


/**
 * Created by CQH on 2016/4/21.
 */
public class FinanceManageActivity extends BaseTopActivity implements View.OnClickListener {
    private TextView bt_id_finance_record;
    private TextView bt_id_finance_raising;
    private TextView bt_id_finance_raisesuccess;
    private TextView bt_id_finance_raisestop;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private Fm_financerecord_Fragment fragmentOne;
    private Fm_raising_Fragment fragmentTwo;
    private Fm_raisesuccess_Fragment fragmentThree;
    private Fm_raisestop_Fragment fragmentFour;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_financemanage);
        Log.i("msg","融资管理");
        initTopBar("融资管理");
        initView();
    }

    public void initView(){
        bt_id_finance_record = (TextView)findViewById(R.id.bt_id_finance_record);
        bt_id_finance_raising = (TextView)findViewById(R.id.bt_id_finance_raising);
        bt_id_finance_raisesuccess = (TextView)findViewById(R.id.bt_id_finance_raisesuccess);
        bt_id_finance_raisestop = (TextView)findViewById(R.id.bt_id_finance_raisestop);
//        Log.i("msg","hahaha3");

        bt_id_finance_record.setOnClickListener(this);
        bt_id_finance_raising.setOnClickListener(this);
        bt_id_finance_raisesuccess.setOnClickListener(this);
        bt_id_finance_raisestop.setOnClickListener(this);
        Log.i("msg","hahaha2");

        manager=getFragmentManager();
        transaction=manager.beginTransaction();
        fragmentOne=new Fm_financerecord_Fragment();
        transaction.add(R.id.fm_id_list, fragmentOne);
        transaction.commit();
        bt_id_finance_record.setTextColor(getResources().getColor(R.color.blue_light));
        Log.i("msg","hahaha1");

    }

    @Override
    public void onClick(View view) {
        transaction=manager.beginTransaction();
        switch (view.getId())
        {
            case R.id.bt_id_finance_record:
                bt_id_finance_record.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_finance_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisestop.setTextColor(getResources().getColor(R.color.text_color));
//                bt_id_finance_record.setBackgroundResource(R.drawable.bt_small_blue_style);
//                bt_id_finance_raising.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisesuccess.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisestop.setBackgroundResource(R.drawable.bt_small_style);
                fragmentOne=new Fm_financerecord_Fragment();
                transaction.replace(R.id.fm_id_list, fragmentOne, "fragmentOne");
                transaction.addToBackStack("fragmentOne");
                break;
            case R.id.bt_id_finance_raising:
                bt_id_finance_record.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raising.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_finance_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisestop.setTextColor(getResources().getColor(R.color.text_color));
//                bt_id_finance_record.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raising.setBackgroundResource(R.drawable.bt_small_blue_style);
//                bt_id_finance_raisesuccess.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisestop.setBackgroundResource(R.drawable.bt_small_style);
                fragmentTwo=new Fm_raising_Fragment();
                transaction.replace(R.id.fm_id_list, fragmentTwo, "fragmentTwo");
                transaction.addToBackStack("fragmentTwo");
                break;
            case R.id.bt_id_finance_raisesuccess:
                bt_id_finance_record.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisesuccess.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_finance_raisestop.setTextColor(getResources().getColor(R.color.text_color));
//                bt_id_finance_record.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raising.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisesuccess.setBackgroundResource(R.drawable.bt_small_blue_style);
//                bt_id_finance_raisestop.setBackgroundResource(R.drawable.bt_small_style);
                fragmentThree=new Fm_raisesuccess_Fragment();
                transaction.replace(R.id.fm_id_list, fragmentThree, "fragmentThree");
                transaction.addToBackStack("fragmentThree");
                break;
            case R.id.bt_id_finance_raisestop:
                bt_id_finance_record.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_finance_raisestop.setTextColor(getResources().getColor(R.color.blue_light));
//                bt_id_finance_record.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raising.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisesuccess.setBackgroundResource(R.drawable.bt_small_style);
//                bt_id_finance_raisestop.setBackgroundResource(R.drawable.bt_small_blue_style);
                fragmentFour=new Fm_raisestop_Fragment();
                transaction.replace(R.id.fm_id_list, fragmentFour, "fragmentFour");
                transaction.addToBackStack("fragmentFour");
                break;
        }
        transaction.commit();
    }
}
